package jdbc;

import model.UserService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "deluser", value = "/deluser")
public class DelUser extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        String idstr =  request.getParameter("ID");
        int id = Integer.parseInt(idstr);
        UserService us = new UserService();
        int r = us.delUser(id);
        if (r == 1) out.print("删除成功");
        else out.print("删除失败");
        out.print("<a href='pages/userList.jsp' >返回用户列表</a>");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
